/**
 * Created by 游永年 on 2019-01-13 16:08.
 * 测试题组件,有听力题和测试题
 */
import React, {Component} from 'react';
import {connect} from 'dva';
import Answer from "./Answer";
import Question from "./Question";
import Full from "../layout/Full";
import Title from "./Title";
import NextButton from "./NextButton";
import PropTypes from 'prop-types';

class TestQuiz extends Component {

  render() {
    const {type, isTimu = false} = this.props;
    return (
      <Full>
        {isTimu ?
          <h1>题目生成中...</h1>
          :
          <div style={{display: 'flex', flexDirection: "column", alignItems: "center"}}>
            {/*模块标题*/}
            <Title/>
            {/*问题显示,现在有听力模块和阅读模块*/}
            <Question/>
            {/*回答用的,选择题*/}
            <Answer/>
            {/*下一光的按钮*/}
            <NextButton type={type}/>
          </div>
        }
      </Full>
    );
  }
}

TestQuiz.propTypes = {
  type: PropTypes.number,
};
TestQuiz.defaultProps = {
  quizList: [],
};
const opts = ({quiz}) => {
  const {quizList = []} = quiz || {};

  return {
    isTimu: quizList.length === 0,
  };
};
export default connect(opts)(TestQuiz);
